home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c
- Subject: Re: swap high and low 16 bits?
- Date: Thu, 18 Jan 1996 01:03:16 GMT
- Organization: Netcom
- Message-ID: <30fd96d2.20527936@nntp.ix.netcom.com>
- References: <Pine.OSF.3.91.960115174921.19742A-100000@io.UWinnipeg.ca> <4dfeko$phv@nntp.crl.com> <Pine.OSF.3.91.960117085702.29067B-100000@io.UWinnipeg.ca>
- NNTP-Posting-Host: ix-dc10-12.ix.netcom.com
- X-NETCOM-Date: Wed Jan 17 5:03:12 PM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- Bill Simpson <wsimpson@uwinnipeg.ca> wrote:
-
- |>On 16 Jan 1996, Bruce Ivey wrote:
- |>
- |>> Bill Simpson (wsimpson@uwinnipeg.ca) wrote:
- |>> : I wanted to obtain a "random" starting number each time a
- program
- |>> : is run. The obvious choice is time(NULL). The problem with it
- is that
- |>> : if the program runs and terminates fairly quickly, the number
- returned by
- |>> : time(NULL) is quite similar each run, differing only by the
- lowest bits.
- |>>
- |>> Why not use a combination of values obtained from your system's
- time of day
- |>> instead of the time the program has been running? Unless the
- program is
- |>> set to run at the same time every day, this should give good
- seeds.
- |>Well I guess you don't realize that time(NULL) returns the time (in
- sec from
- |>Jan 1 1970 or some such thing), not the duration the program has
- been
- |>running.
-
- While this is true on some systems, it is not required by the
- standard. From ISO 7.12.2.4:
-
- The time function determines the current calendar time. The
- encoding of the value is unspecified.
-
-
- Michael M Rubenstein
-